package bg.cinema_system.global;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

public class ConnProperties {

	private static ConnProperties instance = new ConnProperties();
	private Properties properties = new Properties();

	private ConnProperties() {
		try {
			properties.load(loadResourse("ConnecionProperties.properties"));
		} catch (IOException e) {
			throw new RuntimeException(e);
		}
	}

	public static ConnProperties getInstance() {
		if (instance == null) {
			instance = new ConnProperties();
		}
		return instance;
	}

	private InputStream loadResourse(String filename) {
		return getClass().getClassLoader().getResourceAsStream(filename);
	}

	public String getHostname() {
		return properties.getProperty("hostname");
	}

	public String getDatabse() {
		return properties.getProperty("database");
	}

	public String getUsername() {
		return properties.getProperty("username");
	}

	public String getPassword() {
		return properties.getProperty("password");
	}

	public String getDriver() {
		return properties.getProperty("driver");
	}

	public String getPort() {
		return properties.getProperty("port");
	}
}
